<template>
  <!-- <div class="sachertore"> -->
  <div id="sachertorteIndex" :style="{ '--color': `${background_color}` }">
    <c-title :hide="false" text="首页"></c-title>
    <div class="header flex-a-c">
      <div class="search-left flex-a-c" @click="addressTo">
        <span class="address">{{ city || "全国" }}</span>
        <van-icon name="arrow-down" />
      </div>
      <div class="search-right flex" @click.stop="searchNav">
        <div class="left">
          <div class="iconfont icon-sousuo1"></div>
          <input placeholder="请输入关键字搜索" disabled="true" />
        </div>
        <div class="right">搜索</div>
      </div>
    </div>
    <div class="banner" v-if="banner.length > 0">
      <swiper :options="swiperOption" v-if="banner.length">
        <swiper-slide v-for="(item, index) in banner" :key="index">
          <img :src="item.image_url" @click="swiperNav(item.h5_url)" />
        </swiper-slide>
      </swiper>
    </div>
    <div class="notice-bar" v-if="notice">
      <van-notice-bar scrollable color="#FF7D1C" background="#fff" left-icon="volume-o" :text="notice">
        <div slot="left-icon" class="leftIcon">
          <img class="notice-bar_left_icon" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2Fsachertorte%2Fgb%402x.png" alt="" />
        </div>
      </van-notice-bar>
    </div>
    <div class="classify-list" v-if="category.length > 0">
      <template v-for="item in category">
        <div class="classify-item " :key="item.id" v-if="item.adv_url" @click="toAdv(item.adv_url)">
          <img :src="item.adv_img_url ? item.adv_img_url : item.thumb_url" />
          <span class="ell">{{ item.name }}</span>
        </div>
        <div class="classify-item " :key="item.id" @click="classifyNav(item.id, item.name)" v-else>
          <img :src="item.thumb_url" />
          <span class="ell">{{ item.name }}</span>
        </div>
      </template>
    </div>
    <div class="time-buy" v-if="goods.length > 0">
      <div class="time-head flex-a-c flex-j-sb">
        <div class="time-head-left flex-a-c">
          <div class="limit">
            <img class="img_one" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2Fsachertorte%2Ftime%20373%402x.png" alt="" />
            <div class="img_two">
              <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2Fsachertorte%2Ftime%402x.png" alt="" />
              <van-count-down :time="purchaseTime" />
            </div>
          </div>
        </div>
        <div class="time-head-right flex-a-c" @click="purchaseOn">
          <span class="more">更多</span>
          <span class="iconfont icon-member_right"></span>
        </div>
      </div>
      <div class="time-content flex" ref="timeList">
        <div class="flex time-back">
          <div class="timeGoods-item" @click="goodsNav(item.id)" v-for="item in goods" :key="item.id">
            <img :src="item.thumb" />
            <div class="flex-j-sb flex-warp">
              <div class="timeGoods-rush flex">
                <span>￥{{ item.product_price }}</span>
              </div>
              <div class="flex-a-c" style="justify-content: space-between; width: 100%; flex-wrap: wrap;">
                <span class="discount">￥{{ item.market_price }}</span>
                <div class="rush-btn">抢购</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="activity">
      <template v-if="advertising.cat_adv_img_url_1 || advertising.cat_adv_img_url_2 || advertising.cat_adv_img_url_3 || advertising.cat_adv_img_url_4">
        <div class="activity-head flex-a-c">
          <span>精选活动</span>
          <!-- <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/cake/choiceness.png" /> -->
        </div>
        <div class="activity-main flex">
          <div class="activity-left" v-if="advertising.cat_adv_img_url_1">
            <img :src="advertising.cat_adv_img_url_1" @click="adverNav(advertising.cat_adv_url_1)" />
          </div>
          <div class="activity-right">
            <div class="activit-board" v-if="advertising.cat_adv_img_url_2">
              <img :src="advertising.cat_adv_img_url_2" @click="adverNav(advertising.cat_adv_url_2)" />
            </div>
            <div class="activity-footer flex-j-sb">
              <div>
                <img :src="advertising.cat_adv_img_url_3" v-if="advertising.cat_adv_img_url_3" @click="adverNav(advertising.cat_adv_url_3)" />
              </div>
              <div style="border-radius: 0 0 0.5rem 0;">
                <img :src="advertising.cat_adv_img_url_4" v-if="advertising.cat_adv_img_url_4" @click="adverNav(advertising.cat_adv_url_4)" />
              </div>
            </div>
          </div>
        </div>
      </template>
      <div class="handpick" v-if="recommandList.length > 0">
        <div class="handpick-title flex-a-c">
          <span>品牌推荐</span>
          <!-- <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/cake/cake-shop.png" /> -->
        </div>
        <div class="handpick-list" v-for="(item, index) in recommandList" :key="index" @click="toBand(item)">
          <div class="top">
            <img :src="item.logo" alt="" class="usetPhoto" />
            <div class="top_right">
              <div class="bandName">{{ item.name }}</div>
              <div class="localDetail" v-if="item.has_one_store">
                <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2Fsachertorte%2Flocal%20(1)%402x.png" alt="" />
                <span class="detail">{{ item.has_one_store.address }}</span>
                <div class="distance">{{ setDistance(item.has_one_store.distance) }}</div>
              </div>
            </div>
          </div>
          <div class="bandShop">
            <div class="lis" v-for="kitem in item.has_many_goods" :key="kitem.id" @click.stop="goodsNav(kitem.id)">
              <img :src="kitem.thumb" alt="" />
              <div class="shopName">{{ kitem.title }}</div>
              <div class="price">￥{{ kitem.price }}</div>
            </div>
          </div>
        </div>
        <span class="moreTxt" v-if="total_page > page">上拉加载更多...</span>
        <!-- <div class="handpick-list flex" ref="handpickList">
          <div class="content flex">
            <block v-for="item in brand" :key="item.id">
              <div class="handpick-item" @click="handpickNav(item.id)">
                <img :src="item.logo" />
              </div>
            </block>
          </div>
        </div> -->
      </div>
    </div>
  </div>
  <!-- </div> -->
</template>
<script>
import sachertorteIndex from "./sachertorteIndex.js";
export default sachertorteIndex;
</script>
<style lang="scss" scoped>
// ::-webkit-scrollbar {
//   display: none; /* Chrome Safari */
// }
.flex-warp {
  flex-wrap: wrap;
}

.sachertore {
  padding-bottom: 3rem;
}

.ell {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.notice-bar {
  margin: 0 0.75rem;

  .van-notice-bar {
    background: #fceee3 !important;
    padding: 0;
    border-radius: 0.5rem;
    height: 1.88rem;
    font-size: 0.81rem;

    .leftIcon {
      display: flex;
      align-items: center;
      margin-left: 0.75rem;
    }

    .notice-bar_left_icon {
      width: 1.38rem;
      height: 1.38rem;
      border-radius: 100%;
      line-height: 1.88rem;
    }
  }
}

#sachertorteIndex {
  // padding: 0rem 0 1.125rem 0;
  background-color: #f6f6f6;
}

.header {
  flex-wrap: wrap;
  padding: 0.8125rem 0.75rem 0.9375rem 0.75rem;
  background: #fff;

  .search-right {
    cursor: pointer;

    input {
      // width: 18.25rem;
      height: 1.875rem;
      line-height: 1.875rem;
      box-sizing: border-box;
      // padding: 0rem 0 0rem 2.0625rem;
      border: none;
      font-size: 0.75rem;
    }
  }
}

.search-left {
  // flex: 2;
  flex-shrink: 0;
  font-size: 0.875rem;
  margin-right: 0.75rem;

  .icon-ht_more_bottom {
    font-size: 0.5rem;
    color: #999;
    margin-left: 0.125rem;
    margin: 0 0.6875rem 0 0.625rem;
  }

  .address {
    font-size: 0.75rem;
  }
}

.search-right {
  flex: 1;
  background-color: #f6f6f6;
  border-radius: 1.5625rem;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .left {
    flex: 1;
    display: flex;
    align-items: center;

    .icon-sousuo1 {
      padding: 0 0.25rem 0 1rem;
    }
  }

  .right {
    margin-right: 0.13rem;
    flex-shrink: 0;
    width: 3.5rem;
    height: 1.5rem;
    background: var(--color);
    opacity: 1;
    border-radius: 1.09rem;
    text-align: center;
    line-height: 1.5rem;
    color: #fff;
  }
}

.banner {
  padding: 0.75rem;
  box-sizing: border-box;

  img {
    width: 100%;
    border-radius: 0.75rem;
  }
}
// .classify-list {
//   // margin: 0.8125rem 0 0rem 0;
//   // padding: 0 0 0.125rem 0;
//   margin: 0.5rem 0.75rem;
//   padding: 0.75rem;
//   border-radius: 0.5rem;
//   background: #fff;
//   flex-wrap: wrap;
//   display: flex;
//   // justify-content: space-between;
//   &::after {
//     content: "";
//     height: 0;
//     width: calc((100% - 3.3125rem) / 4);
//   }
// }
// .classify-item {
//   flex-shrink: 0;
//   flex-direction: column;
//   // flex: 0 0 calc((100% - 3.3125rem) / 4);
//   // &:nth-child(5) {
//   //   margin-right: 0;
//   // }
//   img {
//     width: 2.75rem;
//     height: 2.75rem;
//     border-radius: 100%;
//   }
//   span {
//     font-size: 0.75rem;
//     margin-top: 0.25rem;
//     // margin: 0.25rem 0 0.5rem 0;
//   }
// }
// .classify-item:nth-child(4n){
//   margin-right: 0;
// }
.classify-list {
  display: flex;
  // justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem;
  margin: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 0.5rem;
  box-sizing: border-box;

  .classify-item {
    width: 25%;
    text-align: center;
    overflow: hidden;
    margin-bottom: 0.75rem;

    img {
      width: 2.75rem;
      height: 2.75rem;
      border-radius: 100%;
    }

    span {
      font-size: 0.75rem;
      margin-top: 0.25rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      // margin: 0.25rem 0 0.5rem 0;
    }
  }
}

.time-buy {
  // padding: 0rem 0.5rem 0.75rem 0.5rem;
  background-color: #fff;
  margin: 0.75rem;
  // margin: 0.625rem 0rem 0rem 0rem;
  border-radius: 0.5rem;
}

.time-head {
  // padding: 0rem 0 0.625rem 0;
  padding: 0.94rem 0.75rem;
}

.time-head-left {
  .limit {
    // background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/cake/purchase-bg.png") center top;
    // background-size: cover;
    // padding: 0.5625rem 0 0rem 0;
    display: flex;

    .img_one {
      width: 2.89rem;
      height: 0.92rem;
      margin-right: 0.28rem;
    }

    .img_two {
      width: 5.84rem;
      height: 1.28rem;
      position: relative;

      img {
        width: 100%;
        height: 100%;
      }

      .van-count-down {
        position: absolute;
        right: 0;
        top: 0;
        font-size: 0.75rem;
        line-height: 1.0625rem;
        color: #cb403e;
        padding: 0.125rem 0.3rem 0.125rem 0.5rem;
        border-radius: 1.0625rem;
        margin: -0.0625rem 0 0 0.5rem;
        // background-color: #fff;
      }
    }
  }

  .icon-naozhong {
    color: #ef5452;
    margin-right: 0.3125rem;
  }

  img {
    width: 2.875rem;
    height: 0.875rem;
  }

  .limit-text {
    font-size: 0.875rem;
    line-height: 0.875rem;
    font-weight: bold;
    color: #fff;
  }
}

.time-head-right {
  // padding: 0.5625rem 0 0 0;
  .more {
    font-size: 0.75rem;
    line-height: 1.0625rem;
    margin-right: 0.1875rem;
    color: #999;
  }

  .icon-member_right {
    font-size: 0.75rem;
    color: #999;
  }
}

.end-time {
  border: 0.0625rem solid #fff;
  border-radius: 0.6875rem;
  padding: 0 0 0 0.5rem;
  margin: 0.5rem 0 0 0.5625rem;

  .title {
    font-size: 0.75rem;
    line-height: 1.0625rem;
    color: #fff;
  }
}

.time-content {
  background-color: #fff;
  padding: 0.75rem;
  overflow: hidden;
  border-radius: 0.5rem;
}

.scroll-view_H {
  height: 7.75rem;
  white-space: nowrap;
  flex-direction: row;
}

.timeGoods-item {
  width: 5.28rem;
  margin-right: 0.59rem;

  img {
    width: 5.28rem;
    height: 5.28rem;
    border-radius: 0.25rem;
  }

  .rush-btn {
    font-size: 0.75rem;
    line-height: 1.03rem;
    // padding: 0.1875rem 0.75rem 0.1875rem 0.75rem;
    // padding: 0 0.75rem;
    background-color: #ef5452;
    color: #fff;
    border-radius: 0.75rem;
    flex-shrink: 0;
    padding: 0.125rem 0.325rem;
  }

  .discount {
    font-size: 0.5313rem;
    line-height: 0.75rem;
    text-decoration: line-through;
    font-weight: 400;
    color: #999;
  }
}

.timeGoods-rush {
  flex-wrap: wrap;
  flex-direction: column;
  padding: 0 0 0.25rem 0;

  span {
    font-size: 0.75rem;
    line-height: 1.03rem;
    text-align: left;
    font-weight: bold;
    color: #e32323;
  }
}

.activity {
  // padding: 0rem 0.75rem 0 0.75rem;
  margin: 0 auto;
  margin-top: 0.75rem;
  // height: 11.47rem;
  width: 21.94rem;
  // background-color: #fff;
}

.activity-head {
  font-size: 1rem;
  font-weight: bold;
  padding: 0.5rem 0 0.6875rem 0;

  .icon-liwu {
    color: #ff7d1c;
    margin-right: 0.25rem;
    font-size: 0.875rem;
    line-height: 0.875rem;
    font-weight: bold;
  }
}

.activity-main {
  background-color: #fff;
  // padding: 0 0 1.25rem 0;
  margin-bottom: 1.25rem;
}

.activity-left {
  border-radius: 0.5rem 0 0 0.5rem;
  width: 11rem;
  height: 11.47rem;
  // margin-right: 0.4375rem;
  // border-radius: 0.5rem;
  overflow: hidden;

  img {
    width: 100%;
    height: 100%;
  }
}

.activity-right {
  width: 10.94rem;
  display: flex;
  flex-direction: column;

  .activit-board {
    width: 100%;
    height: 5.75rem;
    flex-shrink: 0;
    // margin-bottom: 0.5625rem;
    // border-radius: 0.5rem;
    border-radius: 0 0.5rem 0 0;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.activity-footer {
  flex: 1;

  div {
    width: 50%;
    height: 5.72rem;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

/* 精选品牌 */
.handpick {
  // background-color: #fff;
  .handpick-item {
    margin-right: 0.75rem;
    white-space: nowrap;

    img {
      width: 6.25rem;
      height: 6.25rem;
    }
  }
}

.handpick-view_H {
  height: 2.75rem;
  white-space: nowrap;
  flex-direction: row;
}

.handpick-list {
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #fff;
  overflow: hidden;
  // width: 348px;
  // overflow-x: scroll;
  .bandShop {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-start;

    .lis {
      display: flex;
      flex-direction: column;
      margin-right: 0.47rem;
      width: 4.75rem;
      overflow: hidden;

      img {
        width: 4.75rem;
        height: 4.75rem;
        border-radius: 0.25rem;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
      }

      .shopName {
        font-size: 0.75rem;
        color: #333;
        line-height: 1.03rem;
        margin: 0.22rem 0 0.25rem 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .price {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.75rem;
        color: #e32323;
        line-height: 1.03rem;
      }
    }
  }

  .top {
    display: flex;

    .usetPhoto {
      flex-shrink: 0;
      width: 2.5rem;
      height: 2.5rem;
      border-radius: 1.25rem;
      margin-right: 0.25rem;
    }

    .top_right {
      flex: 1;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .bandName {
        font-size: 0.88rem;
        color: #333;
        font-weight: bold;
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .localDetail {
        display: flex;
        align-items: center;
        color: #999;
        font-size: 0.75rem;

        img {
          width: 0.75rem;
          height: 0.75rem;
          flex-shrink: 0;
          margin-right: 0.25rem;
        }

        .detail {
          color: #999;
          flex: 1;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          margin-right: 0.84rem;
          text-align: left;
        }

        .distance {
          flex-shrink: 0;
        }
      }
    }
  }
}

.handpick .handpick-title,
.activity-head text {
  font-size: 1rem;
  font-weight: bold;
  line-height: 1.4375rem;
  color: #333;
}

.recommend-title {
  padding: 1.25rem 0 0.75rem 0;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1.4375rem;
  color: #333;
}

.recommend-title img,
.handpick-title img,
.activity-head img {
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.125rem;
}

.recommend-list {
  flex-wrap: wrap;
}

.moreTxt {
  text-align: center;
  padding: 1rem 0;
  color: #999;
}
// .write {
//   padding: 0 0.125rem;
//   color: #e32323;
// }
// .time-item {
//   font-size: 0.75rem;
//   font-weight: bold;
//   line-height: 1.0625rem;
//   color: #fff;
//   padding: 0.25rem;
//   background-color: #e32323;
//   border-radius: 0.3rem;
// }
</style>
